package com.zwh.autoconfigure.rabbitmq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * topic 交换机， routing key 模糊匹配
 * @author monkey
 * @date 2020/11/3 10:59
 **/
@Configuration
public class TopicExchangeConfig {
    @Bean
    public TopicExchange topicExchange(){
        TopicExchange topicExchange=new TopicExchange("myTopic");
        return topicExchange;
    }
    @Bean
    public Queue topicQueue1() {
        Queue queue=new Queue("topicqueue1");
        return queue;
    }
    @Bean
    public Binding topicBinding1(){
        Binding binding= BindingBuilder.bind(topicQueue1()).to(topicExchange()).with("secondKill.*");//binding key
        return binding;
    }
}
